//
//  MainTableViewController.m
//  明和智能
//
//  Created by 李李善 on 2018/8/23.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "MainTableViewController.h"
#import "UIViewController+NacView.h"
#import "UIBarButtonItem+Extension.h"
#import "MessageTableViewController.h"
#import "MainTableViewCell.h"
@interface MainTableViewController ()

@end

@implementation MainTableViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [self setNavigationBarTranslucent:YES];
    
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [self setNavigationBarTranslucent:NO];
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    //重要位置
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.view.backgroundColor = hexCOLOR(@"ECECEC");
    
    UIBarButtonItem *rightItem = [UIBarButtonItem OnCreateBarBtnItemImage:@"zhuye_xiaoxi_icon" BarBtnstyle:(RightBarBtnItemStyle) Btntag:10 target:self action:@selector(onRightClick:)];
    self.navigationItem.rightBarButtonItem = rightItem;
    
    UIBarButtonItem *leftItem = [UIBarButtonItem OnCreateBarBtnItemImage:@"zhuye_weizhijiantou_icon" ItemName:@"广州" BarBtnstyle:(LeftBarBtnItemStyle) Btntag:20 target:self action:@selector(onRightClick:)];
    UIButton *button = [leftItem.customView viewWithTag:20];
    button.backgroundColor = [UIColor whiteColor];
    [button setNormalTitleColor:[UIColor blackColor]];
    button.cornerRadius = button.height/2;
    button.titleLabel.font = kSysFont(kFitW(11));
    [button layoutButtonWithEdgeInsetsStyle:(MKButtonEdgeInsetsStyleRight) imageTitleSpace:3];
    self.navigationItem.leftBarButtonItem = leftItem;
    
}

-(void)onRightClick:(UIButton *)button
{
    switch (button.tag) {
        case 10:
        {
            MessageTableViewController *vc = [MessageTableViewController new];
            vc.title = @"我的消息";
            [self pushToVC:vc model:nil hideTabBar:YES];
        }
            break;
        case 20:
        {
            [button setNeedsLayout];
            [button layoutButtonWithEdgeInsetsStyle:(MKButtonEdgeInsetsStyleRight) imageTitleSpace:3];
        }
            break;
        default:
        {
            
        }
            break;
    }
}

-(void)onLoadViewByWillAppear:(UIView *)view
{
    [self.tableView config:^(UITableView *tableView) {
        [tableView setSeparatorMan];
    }];
    
}



#pragma mark - Table view data source
-(void)onSetSubviewSELForCell:(BaseTableViewCell *)cell forTableView:(UITableView *)tableView forIndexPath:(NSIndexPath *)indexPath
{
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
    if (indexPath.section==0) {
        if (indexPath.row==0) {
            return [MCCellInfo configForCellId:cell Class:[MainTableViewCell class] Height:kFitH(30)
                                     TableView:tableView];
        }
        return [MCCellInfo configForCellId:cell2 Class:[MainTableViewCell1 class] Height:kFitH(180) TableView:tableView];
        
    }else
    {
        if (indexPath.row==0) {
            return [MCCellInfo configForCellId:cell3 Class:[MainTableViewCell2 class] Height:kFitH(44) TableView:tableView CellStyle:(UITableViewCellStyleValue1)];
        }
        return [MCCellInfo configForCellId:cell4 Class:[MainTableViewCell3 class] Height:kFitH(130) TableView:tableView];
    }
    
}

-(void)onUpdateHeaderView:(BaseTableViewHeaderFooterView *)view model:(id)model atSection:(NSInteger)section
{
    [super onUpdateHeaderView:view model:model atSection:section];
    if (section==1) {
        view.backgroundColor = [UIColor clearColor];
    }
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView HeaderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    if (section==0) {
        return [MCHFViewInfo configForViewId:header1 Class:[MainHeaderFooterView class] Height:kFitH(200) TableView:tableView];
    }
    return [MCHFViewInfo configForViewId:header2 Class:[BaseTableViewHeaderFooterView class] Height:kFitH(10) TableView:tableView];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   return 2;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
